package com.lagou.demo.controller;

import com.lagou.demo.service.IDemoService;
import com.lagou.edu.mvcframework.annotations.LagouAutowired;
import com.lagou.edu.mvcframework.annotations.LagouController;
import com.lagou.edu.mvcframework.annotations.LagouRequestMapping;
import com.lagou.edu.mvcframework.annotations.LagouSecurity;
import com.lagou.edu.mvcframework.pojo.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;


/**
 * @Description: 方法级别注解 wangwu,mazi有访问权限
 * @author liujunling
 * @date 2020/4/20
 */
@LagouController
@LagouRequestMapping("/demo2")
public class MethodSecurityDemoController {


    @LagouAutowired
    private IDemoService demoService;


    /**
     * URL: /demo/query?name=lisi
     * @param request
     * @param response
     * @param username
     * @return
     */
    @LagouRequestMapping("/query")
    @LagouSecurity({"wangwu","mazi"})
    public void query(HttpServletRequest request, HttpServletResponse response,String username) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setView("index.jsp");
        Map<String, Object> model = modelAndView.getModel();
        model.put("username",demoService.get(username));
    }
}
